home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE05 / TYPECAST / RTTI3U.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-11-08  |  1.2 KB  |  58 lines

  1. unit Rtti3u;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, Grids, DBGrids, DB, DBTables, Menus;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     MainMenu1: TMainMenu;
  12.     N1: TMenuItem;
  13.     N2: TMenuItem;
  14.     N3: TMenuItem;
  15.     N4: TMenuItem;
  16.     DataSource1: TDataSource;
  17.     Table1: TTable;
  18.     DBGrid1: TDBGrid;
  19.     procedure TableMenuClick(Sender: TObject);
  20.   private
  21.     { Private declarations }
  22.   public
  23.     { Public declarations }
  24.   end;
  25.  
  26. var
  27.   Form1: TForm1;
  28.  
  29. implementation
  30.  
  31. {$R *.DFM}
  32.  
  33. procedure TForm1.TableMenuClick(Sender: TObject);
  34. begin
  35.   if Sender is TMenuItem then
  36.     { Ensure menu item is last so the Tag references go to it, not the table }
  37.     with Screen, Table1, TMenuItem(Sender) do
  38.     begin
  39.       Cursor := crHourGlass;
  40.       try
  41.         DisableControls;
  42.         Close;
  43.         case Tag of
  44.           1: TableName := 'CUSTOMER';
  45.           2: TableName := 'ORDERS';
  46.           3: TableName := 'ITEMS';
  47.         end;
  48.         if TableName <> '' then
  49.           Open;
  50.         EnableControls;
  51.       finally
  52.         Cursor := crDefault;
  53.       end;
  54.     end;
  55. end;
  56.  
  57. end.
  58.